# -*- coding: utf-8 -*-
from django import forms
from calc.models import item, tipo, projeto



class FormServer(forms.ModelForm):

    class Meta:
        model = item
        fields = ['tipoitem','quantidade',"valor", 'numinterfaces', 'qtdmemory', "qtddiscos", "disco", "componente", "pool"]
        widgets = {"valor": forms.TextInput(attrs={'class':'real_currency input-mini', 'placeholder' : 'valor', 'alt': 'decimal', 'id' : 'id_price'}),
                   "quantidade": forms.TextInput(attrs={'placeholder' :"Qtde Equipamentos", 'class' : "qtde input-mini"}),
                   "qtdmemory": forms.TextInput(attrs={'placeholder' :"ex:16", 'class' : "memory input-mini"}),
                   "disco": forms.TextInput(attrs={'placeholder' :"ex: 300GB sas15k", 'class' : "disco input-small"}),
                    "tipoitem": forms.Select(attrs={'placeholder' :"Selecione ...", 'class' : "quantity input-small"}),
                   "qtddiscos": forms.TextInput(attrs={'placeholder' :"Qtde", 'class' : "qtdediscos input-mini"}),
                   "pool": forms.TextInput(attrs={'placeholder' :"pool", 'class' : "pool input-mini"}),
                   "componente": forms.TextInput(attrs={'placeholder' :"componente", 'class' : "componente input-mini"}),
                   "numinterfaces": forms.TextInput(attrs={'placeholder' :"Qtd Nics", 'class' : "interfaces input-mini"})}
                   
    
    

    def __init__(self, *args, **kwargs):
        super(FormServer, self).__init__(*args, **kwargs)
        
        self.fields['tipoitem'].label = "Tipo:"
        self.fields['tipoitem'].error_messages={'required': '*'}
        self.fields['quantidade'].error_messages={'required': '*'}
        self.fields['quantidade'].label = "Qtde:"
        self.fields['qtdmemory'].error_messages={'required': '*'}
        self.fields['qtdmemory'].label = "Qtde Mem:"
        self.fields['disco'].label= "Disco"
        self.fields['disco'].error_messages={'required': '*'}
        self.fields['qtddiscos'].label = "Qtde Disco"
        self.fields['qtddiscos'].error_messages={'required': '*'}
        self.fields['valor'].label = "Valor"
        self.fields['valor'].error_messages={'required': '*'}
        self.fields['numinterfaces'].label = "Qtd Nics"
        self.fields['numinterfaces'].error_messages={'required': '*'}
        self.fields['tipoitem'].required = True
        self.fields['disco'].required = False
        self.fields['qtddiscos'].required = False
        self.fields['qtdmemory'].required = False
        self.fields['componente'].required = False
        self.fields['pool'].required = False
     
        
        
    
    
    
    
class FormTipo(forms.ModelForm):
    
    class Meta:
        model = tipo
        fields = ['nome','descricao','altura',"consumo"]
        widgets = {"nome": forms.TextInput(attrs={'placeholder' :"Modelo", 'class' : "quantity input-mini"}),
                   "descricao": forms.TextInput(attrs={'placeholder' :"descricao", 'class' : "quantity input-mini"}),
                   "altura": forms.TextInput(attrs={'placeholder' :"Altura", 'class' : "quantity input-mini"}),
                   "consumo": forms.TextInput(attrs={'placeholder' :"Consumo", 'class' : "quantity input-mini"})
                    
                    
                    }
        
        def __init__(self, *args, **kwargs):
            super(FormTipo, self).__init__(*args, **kwargs)
            self.fields['nome'].label = ""
            self.fields['descricao'].label = ""
            self.fields['altura'].label = ""
            self.fields['consumo'].label = ""
            self.fields['nome'].required = True
            self.fields['consumo'].required = True
            self.fields['altura'].required = True
            self.fields['nome'].error_messages={'required': '*'}
            self.fields['altura'].error_messages={'required': '*'}
            self.fields['consumo'].error_messages={'required': '*'}
            
            
            
        
class FormProjeto(forms.ModelForm):
    class Meta:
        model = projeto        
        fields = ['nome']
        widgets = {"nome": forms.TextInput(attrs={'placeholder':"Criar Projeto",'class':"search-query"})}
        
    def __init__(self, *args, **kwargs):
            super(FormProjeto, self).__init__(*args, **kwargs)
            self.fields['nome'].label = ""
            self.fields['nome'].error_messages ={'required': "*"}
            self.fields['nome'].required = True
            
            
        